<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Math对象的用法</title>
  <script>
    /**
     * 1. Math对象的用法
     */
    function fun1(){
      // 1.1 圆周率的值
      let pi = Math.PI
      console.log("pi = ",pi)
      // 1.2 求绝对值
      let abs = Math.abs(-10)
      console.log("abs = ",abs)
      // 1.3 返回指定数的n次幂
      let pow = Math.pow(2,3)
      console.log("pow = ",pow)
      // 1.4 求平方根
      let sqrt = Math.sqrt(3)
      console.log("sqrt: ",sqrt)
      // 1.5 返回四舍五入的结果
      let round = Math.round(3.556)
      console.log("round = ",round)
      // 1.6 求最大值与最小值
      let max = Math.max(1,2,3,4,5)
      let min = Math.min(1,2,3,4,5)
      console.log("max = ",max)
      console.log("min = ",min)
      // 1.7 返回比给定数小的最大整数
      let floor = Math.floor(3.14)
      console.log("floor = ",floor)
      // 1.8 返回比给定数大的最小整数
      let ceil = Math.ceil(3.14)
      console.log("ceil = ",ceil)
      // 1.9 返回[0,1)的随机数
      let random = Math.random()
      console.log("random = ",random)
      // 1.10 返回指定弧度的正弦值
      let sin = Math.sin(Math.PI/3)
      console.log("sin = ",sin)
    }
    fun1()
  </script>
</head>
<body>

</body>
</html>
